package com.itheima.d6_stream;

import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 获取Stream流对象
 */
public class StreamDemo1 {
    public static void main(String[] args) {
        //1.获取集合的Stream流对象
        Collection<String> coll = new ArrayList<>();
        Stream<String> s1 = coll.stream();

        //2.Map集合获取Stream流
        Map<String, Integer> map = new HashMap<>();
        //获取键流
        Stream<String> s2 = map.keySet().stream();
        //获取值流
        Stream<Integer> s3 = map.values().stream();
        //获取键值流
        Stream<Map.Entry<String, Integer>> s4 = map.entrySet().stream();

        //2.获取数组的Stream流
        String[] names = {"有村架纯","阮秀","宁姚","小松菜奈"};

        //方式1：Arrays.stream（静态方法）
        Stream<String> s5 = Arrays.stream(names);

        //方式2：Stream.of（静态方法）
        Stream<String> s6 = Stream.of(names);

        Stream<String> s7 = Stream.of("小松菜奈", "小松菜奈", "小松菜奈", "小松菜奈", "小松菜奈");
        System.out.println(s7.count());


    }
}
